﻿{include file="common/header1" /}
<div class="user w1200">
    <p class="title">Personal center</p>
    <div class="user_con flex">
        <div class="user_nav">
            <a href="/member">Personal information</a>
            <a href="/index/Member/orders">Order list</a>
            <a href="/index/Member/address" class="active">My address</a>
            <a href="javascript:;" id="logOut">Log Out</a>
        </div>
        <div class="user_right">
            <div class="user_right_box">
                <form class="form" onsubmit="return false;" id="thisForm" method="post" enctype="multipart/form-data">
                    <div class="user_inf_box">
                        <input type="text" disabled value="Name">
                        <input name="name" type="text" value="" style="width: 100%;">
                    </div>

                    <div class="user_inf_box" id="province_span">
                        <input type="text" disabled value="省">
                        <select id="province" name="province">
                            <option value="">请选择省份</option>
                            {foreach name="province" item="pvc"}
                            <option value="{$pvc.id}.{$pvc.name}">{$pvc.name}</option>
                            {/foreach}
                        </select>
                    </div>
                    <div class="user_inf_box" id="city_span">
                        <input type="text" disabled value="市">
                        <select id="city" name="city">

                        </select>
                    </div>
                    <div class="user_inf_box" id="district_span">
                        <input type="text" disabled value="区">
                        <select id="district" name="area">

                        </select>
                    </div>

                    <div class="user_inf_box">
                        <input type="text" disabled value="Address">
                        <input type="text" name="address" value="" style="width: 100%;">
                    </div>

                    <div class="user_inf_box">
                        <input type="text" disabled value="Phone">
                        <input name="phone" type="text" value="" style="width: 100%;">
                    </div>
                    <input type="checkbox" name="is_default" value="1">Set Default
                    <button class="address_btn" id="submitAddAddress">ADD</button>
                </form>

            </div>
        </div>
    </div>

</div>

<script>
    /* ★☆★☆★☆★☆★☆★☆★☆ 地区联动菜单 START ★☆★☆★☆★☆★☆★☆★☆ */
    {if empty($edit_address.city)}$("#city_span").hide();{/if}
        {if empty($edit_address.area)}$("#district_span").hide();{/if}

            //初始化数据
            var url = '/index/Member/region'; //后台地址

            $("select[name='province']").change(function () { //监听下拉列表的change事件
                var region_id = $(this).val(); //获取下拉列表选中的值
                //发送一个post请求
                $.ajax({
                    type: 'post',
                    url: url,
                    data: {key: region_id},
                    dataType: 'json',
                    success: function (data) { //请求成功回调函数
                        var m_status = data.status;
                        var datalist = data.data

                        if (m_status == 200) { //判断状态码，200为成功
                            $("#city_span").show();
                            $("#district_span").hide();
                            var option = '';
                            console.log(data)
                            option = '<option value="">请选择城市</option>';
                            for (var i = 0; i < datalist.length; i++) { //循环获取返回值，并组装成html代码
                                option += '<option value="' + datalist[i].id + '.' + datalist[i].name + '">' + datalist[i].name + '</option>';
                            }
                            $("#city").html(option); //js刷新第二个下拉框的值
                        } else {
                            $("#city_span").hide();
                            $("#district_span").hide();
                        }
                    }, error: function (data) {

                    }
                });
            });

            $("select[name='city']").change(function () { //监听下拉列表的change事件
                var region_id = $(this).val(); //获取下拉列表选中的值
                //发送一个post请求
                $.ajax({
                    type: 'post',
                    url: url,
                    data: {key: region_id},
                    dataType: 'json',
                    success: function (data) { //请求成功回调函数
                        var m_status = data.status;
                        var datalist = data.data

                        if (m_status == 200) { //判断状态码，200为成功
                            $("#district_span").show();
                            var option = '';
                            console.log(data)
                            option = '<option value="">请选择县区</option>';
                            for (var i = 0; i < datalist.length; i++) { //循环获取返回值，并组装成html代码
                                option += '<option value="' + datalist[i].id + '.' + datalist[i].name + '">' + datalist[i].name + '</option>';
                            }
                            $("#district").html(option); //js刷新第二个下拉框的值
                        } else {
                            $("#district_span").hide();
                        }
                    }, error: function (data) {

                    }
                });
            });
    /* ★☆★☆★☆★☆★☆★☆★☆ 地区联动菜单 END ★☆★☆★☆★☆★☆★☆★☆ */

</script>
{include file="common/footer" /}


